<template>
<view>
	<view class='nav' :style="'height:'+navH1+'px;'">
		<view class="input_view" :style="'position:absolute;top:'+navH+'px;height:'+ navH2+'px'">
			<view class="" :class="acitve==0?'active':''" @click="acitve=0">系统推荐</view>
			<view class="" :class="acitve==1?'active':''" @click="acitve=1">人工推荐</view>
			<view class="" :class="acitve==2?'active':''" @click="acitve=2">智能推荐</view>
		</view>
	</view>
	<view class="" :style="'height:'+navH1+'px;'"></view>
	
	<view class="box_item" v-for="(item,index) in companyList" :key='index' @click="toDetail(item)">
		<image class="image" :src="item.logo"></image>
		<view class="name1">
			<view class="flex_c">
				<view class="name">{{item.company_name}}</view>
				<view class="name">{{item.score}}</view>
			</view>
			<view class="">
				<view class="chain_name" v-if="item.chain_name&&item.chain_name.length>0">{{item.chain_name[0]}}</view>
				<view class="chain_name1" v-if="item.label_name&&item.label_name.length>0">{{item.label_name[0]}}</view>
			</view>
			<view class="flex_c">
				<view class="info" style="font-size: 12px; color: #666;margin: 6px 0;">{{item.name.length>50?item.name.substr(0,50)+'...':item.name}} </view>
				<view class="" style="font-size: 12px; color: #666;margin: 6px 0;">{{item.createtime.split(' ')[0].split('-')[1]+'-'+item.createtime.split(' ')[0].split('-')[2]}}</view>
			</view>
		</view>
	</view>
	<endlist :isLoad='isLoad' :isfinsh='isfinsh' :length='companyList.length'></endlist>
	<view class="" style="height: 80px;width: 100%;"></view>
	<Tabbar :current="3"></Tabbar>
</view>
</template>

<script>
	import Tabbar from '@/components/tabbar.vue'
	import endlist from '@/components/endlist.vue'
	import {xx ,GetBusinessclueList,GetMessageType} from '../../utils/api.js' 
	export default {
		data() {
			return {
				page:1,
				isNewRenderDone:true,
				list:[{name:'',chain_name:[],label_name:[]}],
				acitve:0,
				companyList:[],
				typeList:[],
				page1:1,
				navH: uni.getStorageSync('navH'),
				navH1: uni.getStorageSync('navH1'),
				navH2: uni.getStorageSync('navH2'),
				isLoad:false,
				isfinsh:false
			}
		},
		onShow(){
			if(!uni.getStorageSync('xm_token')){
				uni.redirectTo({
					url:'/pages/login/login?type=重点招商线索推荐'
				})
				return
			}
			this.getCList()
		},
		components:{Tabbar,endlist},
		watch:{
			acitve:function(){
				this.companyList = []
				this.isLoad=false
				this.isfinsh=false
				this.page1 = 1
				this.getCList()
			}
		},
		methods: {
			toDetail(item){
				uni.navigateTo({
					url:'/pages/companyDetail/companyDetail?identification='+item.identification
				})
			},
			getCList(){
				uni.showLoading({ mask:true,
					title:'正在加载'
				})
				GetBusinessclueList({page:this.page1,from:(this.acitve+1)}).then(res=>{
					if(this.page1==1){
						this.companyList= res.data.data
					}else{
						this.companyList.push(...res.data.data)
					}
					console.log(this.companyList)
					this.isNewRenderDone=true
					uni.hideLoading()
				})
			},
		},
		onReachBottom() {
			// 加锁，避免在加载更多时用户频繁下拉导致的重复触发而渲染异常
			if(!this.isNewRenderDone) return;   
			this.isNewRenderDone = false
			// 模拟分页请求 (加载更多)
			if(this.active==1){
				this.page+=1
				this.getList()
			}else{
				this.page1 += 1
				this.getCList()
			}
			
		},
	}
</script>

<style scoped lang="scss">
.xx_l{
	width: calc(100% - 60px);
}
.btn_c{
	width: 50px;
	height: 28px;
	font-size: 14px;
	background-color: #ff9933;
	color: #fff;
	border-radius: 4px;
	line-height: 28px;
	text-align: center;
}
.item_xx{
	width: calc(100% - 28px);
	padding: 10px 14px;
	border-bottom: 1px solid #E5E5E5;
	display: flex;
	align-items: center;
	justify-content: space-between;
	&:active{
		background-color: rgba($color: #000000, $alpha: .1);
	}
	.time{
		font-size: 12px;
		color: #888;
		display: flex;
		justify-content: space-between;
	}
	.red{
		color: red;
	}
	.orange{
		color: #ff9933;
	}
	.name{
		position: relative;
		font-size: 14px;
		color: #333;
		margin-bottom: 6px;
	}
	.new::after{
		position: absolute;
		content:' ';
		width: 10px;
		font-size: 10px;
		top: 0px;
		left: -14px;
		border-radius: 5px;
		background: #red;
	}
	image{
		width: 36px;
		height: 36px;
		margin-right: 14px;
	}
	.title{
		font-size: 15px;
		width: calc(100% - 50px);
		position: relative;
		&::after{
			position: absolute;
			content: ' ';
			right: 0;
			top: 6px;
			width: 8px;
			height: 8px;
			border-top: 1px solid #888;
			border-right: 1px solid #888;
			transform: rotate(45deg);
		}
	}
}
.nav{
	width: 100%;
	position: fixed;
	top: 0;
	left: 0;
	background-color: rgba($color: #fff, $alpha: 1);
	z-index: 10;
	transition: all 0.5s;
}
.input_view{
	display: flex;
	width: 100%;
	// justify-content: center;
	padding-left:12px;
	align-items: center;
	view{
		width: 70px;
		margin-right: 20px;
		text-align: center;
		color: #888;
	}
	.active{
		font-size: 17px;
		font-weight: 800;
		color: #222;
		position: relative;
		&::after{
			position: absolute;
			content: ' ';
			bottom: -4px;
			width: 30px;
			height: 3px;
			border-radius: 1.5px;
			background-color: #0091FF;
			left: 20px;
		}
	}
}
	.box_item{
		width: calc(100% - 44px);
		margin: 10px 10px;
		background: #FFFFFF;
		box-shadow: 0px 2px 2px 2px rgba(191, 191, 191, 1);
		border-radius: 6px;
		display: flex;
		padding: 12px;
		position: relative;
		.image{
			width: 36px;
			height: 36px;
			margin-right: 8px;
		}
		.score1{
			position: absolute;
			right: 10px;
			font-size: 12px;
			color: #333;
		}
		.score{
			position: absolute;
			right: 16px;
			font-size: 22px;
			color: #0091FF;
			.sc{
				width: 24px;
				margin:0;
			}
		}
		.name1{
			width: calc(100% - 50px);
		}
		.name{
			font-size: 15px;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 600;
			color: #333;
			line-height: 21px;
		}
		.info{
			font-size: 12px;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #999999;
			line-height: 17px;
		}
	}
	.flex_c{
		display: flex;
		justify-content: space-between;
		align-items: center;
		.info{
			width: calc(100% - 40px);
		}
	}
	.chain_name{
		padding: 2px 4px;
		border-radius: 2px;
		font-size: 12px;
		color: #ff9933;
		background-color: rgba($color: #ff9933, $alpha: .1);
		display: inline-block;
		margin: 8px 6px 4px 0;
	}
	.chain_name1{
		padding: 2px 4px;
		margin: 8px 6px 4px 0;
		border-radius: 2px;
		font-size: 12px;
		color: #227aff;
		display: inline-block;
		background-color: rgba($color: #227aff, $alpha: .1);
	}
</style>
